package tcln.gxtx.client.widget.form.model;

import com.extjs.gxt.ui.client.data.BaseModelData;

/**
 * A basic combobox model for a combobox.
 * 
 * @param <ID>
 *            Class type of field 'id'.
 * @author Truong Chau Lien Ngoc (lienngoc@gmail.com)
 */
public class SimpleComboBoxModel<ID> extends BaseModelData {
    private static final long serialVersionUID = 1L;

    /**
     * Name of property 'value'.
     */
    public static final String PROPERTY_VALUE = "value";

    /**
     * Name of property 'id'.
     */
    public static final String PROPERTY_ID = "id";

    /**
     * Returns current unique ID of this model in its combobox.
     * 
     * @return
     */
    @SuppressWarnings("unchecked")
    public ID getId() {
        return (ID) get(PROPERTY_ID);
    }

    /**
     * Sets new unique ID of this model in its combobox.
     * 
     * @param id
     *            the new id to set
     */
    public void setId(ID id) {
        set(PROPERTY_ID, id);
    }

    /**
     * Returns current display value of this model in its combobox.
     * 
     * @return the {@link #value}.
     */
    public String getValue() {
        return get(PROPERTY_VALUE);
    }

    /**
     * Sets new display value of this model in its combobox.
     * 
     * @param value
     *            the new value to set
     */
    public void setValue(String value) {
        set(PROPERTY_VALUE, value);
    }
}
